<?php

namespace App\Jobs;

use App\Models\Members\MemberPlat;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;


class TestJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Create a new job instance.
     *
     * @return void
     */

    public $tries = 5; // 最大尝试次数
    public $timeout = 120; // 超时时间

    private $order;

    public function __construct($order)
    {
        //

        $this->order = $order;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        // 处理订单
        //self::dispatch('dasdfadsforeder------order')->onQueue('testRedis');
        // php artisan queue:restart
        // php artisan queue:work redis --queue=testRedis
        MemberPlat::create(
            [
                'user_uid' => $this->order,
                'plat' => 5,
            ]
        );
    }

    public function failed(\Exception $exception)
    {
        // 给用户发送失败通知，等等...
    }
}
